home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Leser 15 / Amiga Plus Leser CD 15.iso / Online / newscoaster / Rexx / after_fetchPL.rexx next >
OS/2 REXX Batch file  |  2002-03-12  |  3KB  |  89 lines

  1. /* ISO-8859-2 to AmigaPL conversion for NewsCoaster */
  2. /* by Grzegorz Kraszewski (Krashan^BlaBla) <krashan@amiga.org.pl> */
  3. /* $VER: NewsCoasterPL 1.0 (30.4.2000) BLABLA PRODUCT */
  4.  
  5. OPTIONS RESULTS
  6. ADDRESS "NEWSCOASTER"
  7.  
  8. IF ~Show("L","rexxsupport.library") THEN CALL AddLib("rexxsupport.library", 0, -30)
  9.  
  10. iso88592 = "±æê³óñ¶¼¿¡ÆÊ£ÑÓ¦¬¯"
  11. amigapl = "âêëîóïôúûÂÊËÎÓÏÔÚÛ"
  12. encoding = "8bit"
  13.  
  14. SetFolderByName "pl.comp.sys.amiga"
  15. FolderInfo
  16. fldinfo = RESULT
  17. PARSE VAR fldinfo numer " "
  18. folderpath = "NewsCoasterData:Folder_" || numer
  19.  
  20. lista = ShowDir(folderpath,"F",":")
  21. DO WHILE lista ~= ""
  22.   PARSE VAR lista filename ":" lista
  23.   IF Upper(Left(filename,5)) = "NEWS_" THEN
  24.     DO
  25.       filename = folderpath || "/" || filename
  26.       newname = filename || ".BB"
  27.       IF Open(file1,filename,"R") THEN
  28.         DO
  29.           IF Open(file2,newname,"W") THEN
  30.             DO
  31.               DO WHILE ~Eof(file1)
  32.                 line = ReadLn(file1)
  33.                 IF Upper(Left(line,27)) = "CONTENT-TRANSFER-ENCODING: " THEN
  34.                   DO
  35.                     PARSE VAR line " " encoding
  36.                     encoding = Strip(encoding,"T",D2C(13))
  37.                   END
  38.                 SELECT
  39.                   WHEN encoding == "8bit" THEN DO
  40.                     line = Translate(line,amigapl,iso88592)
  41.                   END
  42.                   WHEN encoding == "quoted-printable" THEN DO
  43.                     CALL QPTranslate(line)
  44.                   END
  45.                   OTHERWISE
  46.                 END
  47.                 WriteLn(file2,line)
  48.               END
  49.               Close(file2)
  50.             END
  51.           Close(file1)
  52.           Delete(filename)
  53.           Rename(newname,filename)
  54.         END 
  55.     END
  56.   Say (encoding || "!")
  57. END
  58. EXIT
  59.  
  60. QPTranslate:
  61.   actual = 1
  62.   DO FOREVER
  63.     actual = Pos("=",line,actual)
  64.     IF actual = 0 THEN RETURN
  65.     actual = actual + 1
  66.     code = Substr(line,actual,2)
  67.     SELECT
  68.       WHEN code = "B1" THEN code = "E2"        /* â */
  69.       WHEN code = "A1" THEN code = "C2"         /* Â */
  70.       WHEN code = "E6" THEN code = "EA"         /* ê */
  71.       WHEN code = "C6" THEN code = "CA"         /* Ê */
  72.       WHEN code = "EA" THEN code = "EB"        /* ë */
  73.       WHEN code = "CA" THEN code = "CB"        /* Ë */
  74.       WHEN code = "B3" THEN code = "EE"        /* î */
  75.       WHEN code = "A3" THEN code = "CE"        /* Î */
  76.       WHEN code = "F1" THEN code = "EF"        /* ï */
  77.       WHEN code = "D1" THEN code = "CF"        /* Ï */
  78.       WHEN code = "B6" THEN code = "F4"        /* ô */
  79.       WHEN code = "A6" THEN code = "D4"        /* Ô */
  80.       WHEN code = "BC" THEN code = "FA"        /* ú */
  81.       WHEN code = "AC" THEN code = "DA"        /* Ú */
  82.       WHEN code = "BF" THEN code = "FB"        /* û */
  83.       WHEN code = "AF" THEN code = "DB"        /* Û */
  84.     OTHERWISE
  85.     END
  86.     IF code ~= "" THEN line = Overlay(code,line,actual)
  87.   END
  88. RETURN
  89.